import { IPSCodeList } from '../../codelist/ipscode-list';
import { IPSListDataItem } from './ipslist-data-item';
import { PSDataItemImpl } from '../../data/psdata-item-impl';

export class PSListDataItemImpl extends PSDataItemImpl implements IPSListDataItem {
  protected frontpscodelist: IPSCodeList | null = null;

  getFrontPSCodeList(): IPSCodeList | null {
    if (this.frontpscodelist != null) return this.frontpscodelist;
    const value = this.M.getFrontPSCodeList;
    if (value == null) {
      return null;
    }
    this.frontpscodelist = this.getPSModel4('codelist.IPSCodeList', value, 'getFrontPSCodeList') as IPSCodeList;
    return this.frontpscodelist;
  }

  get frontPSCodeList(): IPSCodeList | null {
    return this.getFrontPSCodeList();
  }

  getFrontPSCodeListMust(): IPSCodeList {
    const value = this.getFrontPSCodeList();
    if (value == null) {
      throw new Error('未指定前端代码表');
    }
    return value;
  }

  get groupItem(): string {
    return this.M.groupItem;
  }

  get scriptCode(): string {
    return this.M.scriptCode;
  }

  get customCode(): boolean {
    return this.M.customCode != null ? this.M.customCode : false;
  }

  get cls(): string {
    return 'PSListDataItemImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'control.list.IPSListDataItem') return true;
    return super.instanceof(cls);
  }
}
